from __future__ import annotations

from dataclasses import dataclass
from math import sqrt, radians, tan


@dataclass
class ObservationValue:
    expected_reading: float
    note: str


def equal_length_method(sag_m: float, instrument_height_m: float) -> ObservationValue:
    """等长法观测值：取两端等距，读数≈弧垂+仪器高差修正（简化）。"""

    reading = sag_m + instrument_height_m * 0.0
    return ObservationValue(expected_reading=reading, note="简化：读数≈弧垂")


def unequal_length_method(sag_m: float, ratio: float) -> ObservationValue:
    """异长法：按比例换算目标读数（简化）。"""

    reading = sag_m * ratio
    return ObservationValue(expected_reading=reading, note="按比例折算")


def angle_method(span_m: float, angle_deg: float) -> ObservationValue:
    """角度法：由视线角反算弧垂 f ≈ 0.5·l·tanθ（小角度近似）。"""

    theta = radians(angle_deg)
    f = 0.5 * span_m * tan(theta)
    return ObservationValue(expected_reading=f, note="小角度近似")


